package hadix.time

import hadix.Info
import org.apache.commons.lang.time.DateUtils
import org.apache.commons.lang.time.DurationFormatUtils

/**
 * User: hadix
 * Date: 13-7-9
 * Time: PM10:03
 */
class TimeValidatorZl extends TimeValidator {
    TimeValidatorZl(int overtime) {
        super(overtime >= 24 ? overtime : 24)
    }

    @Override
    boolean isExpired(Info info) {
        def publishTime = DateUtils.parseDate(info.time, "yyyy-MM-dd")
        long start = publishTime.getTime()
        long end = System.currentTimeMillis()
        String d = DurationFormatUtils.formatDuration(end - start, 'HH')
        return Integer.parseInt(d) > overtime
    }
}
